package a.f.h.f.a;

import a.c.*;
import a.c.d;
import a.c.k;
import a.c.m;

import java.util.ArrayList;

public class p
  extends o
{
  boolean[] n;
  int[] o;
  int[] p;
  boolean[] q;
  boolean[] r;
  ArrayList s;
  boolean t;
  bb u;
  k v;
  public static int w;
  
  public void b(k paramk)
  {
    this.v = paramk;
  }
  
  private bb c(bb parambb)
  {
    int j = e.i;
    boolean bool = e.h;
    a();
    this.u = new bb();
    this.s = new ArrayList();
    bb localbb = new bb();
    w localw = this.a.v();
    a.c.e locale1;
    label122:
    do
    {
      if (!localw.e()) {
        break;
      }
      locale1 = localw.d();
      if (bool) {
        break label160;
      }
      if (this.n[locale1.f()] != 0)
      {
        if (j != 0) {
          break label122;
        }
        if (this.o[locale1.f()] == 0) {
          localbb.add(locale1);
        }
      }
      if (j == 0)
      {
        if (this.n[locale1.f()] == 0) {
          this.s.add(locale1);
        }
        localw.f();
      }
    } while (!bool);
    if (j == 0)
    {
      if (this.b)
      {
        label160:
        localw = a(localbb.l());
        if (j != 0) {
          break label193;
        }
        if (!bool) {}
      }
      else
      {
        localw = localbb.l();
      }
      label193:
      do
      {
        if (!localw.e()) {
          break;
        }
        if (j != 0) {
          break label250;
        }
        this.u.c(localw.d());
        localw.f();
        if (bool) {
          break label249;
        }
      } while (!bool);
    }
    if (j == 0) {
      this.q = new boolean[this.a.k()];
    }
    label249:
    label250:
    this.r = new boolean[this.a.k()];
    label275:
    label435:
    label495:
    label628:
    do
    {
      for (;;)
      {
        if (parambb.size() < this.a.k())
        {
          do
          {
            for (;;)
            {
              if (!this.u.isEmpty())
              {
                locale1 = this.u.o();
                this.r[locale1.f()] = true;
                if (this.p[locale1.f()] == 0)
                {
                  parambb.add(locale1);
                  if (j != 0) {
                    break;
                  }
                  if (bool) {
                    break label648;
                  }
                  if (this.q[locale1.f()] != 0) {
                    throw new RuntimeException("UpwardGT: already seen node " + locale1);
                  }
                  this.q[locale1.f()] = true;
                  m localm;
                  if ((j != 0) || (this.b))
                  {
                    localm = a(locale1.m());
                    if (j != 0) {
                      break label435;
                    }
                    if (!bool) {}
                  }
                  else
                  {
                    localm = locale1.m();
                  }
                  Object localObject2;
                  do
                  {
                    do
                    {
                      if (!localm.e()) {
                        break label495;
                      }
                      localObject1 = localm.a();
                      if (bool) {
                        break;
                      }
                      if (this.v.getBool(localObject1))
                      {
                        localObject2 = ((d)localObject1).e();
                        this.u.c(localObject2);
                      }
                      localm.f();
                    } while (!bool);
                  } while (j != 0);
                  Object localObject1 = locale1.l();
                  if (((m)localObject1).e())
                  {
                    localObject2 = ((m)localObject1).a();
                    a.c.e locale2 = ((d)localObject2).a(locale1);
                    int i = locale2.f();
                    if (!bool)
                    {
                      if (this.q[i] == 0)
                      {
                        if (j != 0) {
                          break label628;
                        }
                        if (a(locale2, (d)localObject2))
                        {
                          this.p[i] -= 1;
                          if (j != 0) {
                            break label628;
                          }
                          if (a(locale2)) {
                            this.u.c(locale2);
                          }
                        }
                      }
                      this.c[i] -= 1;
                      ((m)localObject1).f();
                      if (!bool) {
                        break label275;
                      }
                    }
                  }
                }
              }
            }
          } while (j != 0);
          this.t = false;
          if (!this.s.isEmpty()) {
            if (j == 0) {
              if (!bool) {
                if (!this.t)
                {
                  a(this.f, this.g);
                  if (j == 0) {
                    if (this.g.isEmpty()) {
                      a(this.s, this.g);
                    }
                  }
                  if (j == 0)
                  {
                    if (this.g.isEmpty()) {
                      throw new RuntimeException("UpwardGT: Graph contains a directed circle");
                    }
                    a(this.s, this.g, this.f, parambb);
                  }
                  if (!bool) {
                    break;
                  }
                }
              }
            }
          }
        }
      }
      parambb.j();
    } while (j != 0);
    label648:
    return parambb;
  }
  
  protected void a()
  {
    int k = e.i;
    boolean bool = e.h;
    this.n = new boolean[this.a.k()];
    this.c = new int[this.a.k()];
    this.o = new int[this.a.k()];
    this.p = new int[this.a.k()];
    w localw = this.a.v();
    label193:
    label205:
    do
    {
      if (!localw.e()) {
        break;
      }
      a.c.e locale = localw.d();
      int i = 0;
      int j = 0;
      m localm = locale.n();
      do
      {
        do
        {
          if (!localm.e()) {
            break label205;
          }
          d locald = localm.a();
          if (bool) {
            break;
          }
          if (a(locald))
          {
            if (k == 0)
            {
              if (this.v.getBool(locald))
              {
                i++;
                this.n[locald.e().f()] = true;
                this.n[locald.f().f()] = true;
              }
            }
            else
            {
              if (k != 0) {
                continue;
              }
              if (!bool) {
                break label193;
              }
            }
            j++;
          }
          localm.f();
        } while (!bool);
        this.c[locale.f()] = locale.c();
        this.o[locale.f()] = i;
        this.p[locale.f()] = j;
        localw.f();
      } while (k != 0);
    } while (!bool);
  }
  
  protected void a(ArrayList paramArrayList1, ArrayList paramArrayList2)
  {
    int m = e.i;
    boolean bool = e.h;
    paramArrayList2.clear();
    int i = 2147483647;
    int j = 0;
    do
    {
      if (j >= paramArrayList1.size()) {
        break;
      }
      a.c.e locale = (a.c.e)paramArrayList1.get(j);
      int k = this.c[locale.f()];
      if ((m != 0) || (this.p[locale.f()] <= 0))
      {
        if (m == 0)
        {
          if (k < i)
          {
            i = k;
            paramArrayList2.clear();
          }
          if (m != 0) {
            continue;
          }
        }
        if (k == i) {
          paramArrayList2.add(locale);
        }
      }
      j++;
    } while (!bool);
  }
  
  public void a(ArrayList paramArrayList1, ArrayList paramArrayList2, ArrayList paramArrayList3, bb parambb)
  {
    int k = e.i;
    boolean bool = e.h;
    if (k == 0) {}
    a.c.e locale1 = this.b ? a(paramArrayList2) : (a.c.e)paramArrayList2.get(0);
    int i = paramArrayList1.indexOf(locale1);
    if (k == 0) {
      if (i >= 0) {
        paramArrayList1.remove(i);
      }
    }
    parambb.add(locale1);
    this.q[locale1.f()] = true;
    paramArrayList3.clear();
    m localm = locale1.l();
    label208:
    do
    {
      if (!localm.e()) {
        break;
      }
      d locald = localm.a();
      a.c.e locale2 = locald.a(locale1);
      int j = locale2.f();
      if (k == 0)
      {
        if (this.q[j] == 0)
        {
          if (k == 0) {
            if (a(locale2, locald))
            {
              this.p[j] -= 1;
              if (k != 0) {
                break label208;
              }
              if (a(locale2))
              {
                this.u.c(locale2);
                this.t = true;
              }
            }
          }
          if (k != 0) {
            continue;
          }
          if (this.n[j] == 0) {
            paramArrayList3.add(locale2);
          }
        }
        this.c[j] -= 1;
        localm.f();
      }
    } while (!bool);
  }
  
  private m a(m paramm)
  {
    d[] arrayOfd = new ab(paramm).p();
    this.h.a(arrayOfd);
    return new ab(arrayOfd).l();
  }
  
  private w a(w paramw)
  {
    a.c.e[] arrayOfe = new bb(paramw).p();
    this.h.a(arrayOfe);
    return new bb(arrayOfe).l();
  }
  
  private boolean a(a.c.e parame)
  {
    int i = e.i;
    if (((i != 0) || (this.n[parame.f()] != 0)) && ((i != 0) || (this.r[parame.f()] != 0))) {
      if (i != 0) {}
    }
    return this.p[parame.f()] == 0;
  }
  
  private boolean a(a.c.e parame, d paramd)
  {
    return ((e.i != 0) || (!this.v.getBool(paramd))) && (a(paramd)) && (paramd.e() == parame);
  }
  
  private boolean a(d paramd)
  {
    if (e.i == 0) {}
    return this.k.getInt(paramd) == 1;
  }
  
  public void a(bb parambb)
  {
    parambb.clear();
    c(parambb);
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.f.h.f.a.p

 * JD-Core Version:    0.7.0.1

 */